package main

import (
	"fmt"
	"time"
)

func timeSub(t1, t2 time.Time) int {
	t1 = time.Date(t1.Year(), t1.Month(), t1.Day(), 0, 0, 0, 0, time.Local)
	t2 = time.Date(t2.Year(), t2.Month(), t2.Day(), 0, 0, 0, 0, time.Local)

	return int(t1.Sub(t2).Hours() / 24)
}





func main()  {
	//2个时间差是多少天

	//t1 := time.Date(2018, 1, 10, 0, 0, 1, 100, time.UTC)
	t1 := time.Now()
	t2 := time.Date(2020, 10, 12, 23, 59, 22, 100, time.Local)
	//if timeSub(t1, t2) != 1 {
	//	panic(fmt.Sprintf("just one day: should return 1 but got %v", timeSub(t1, t2)))
	//}
	num := timeSub(t1,t2)
	fmt.Println("------>", num)
	fmt.Println("--------", t1)
	fmt.Println("--------", t2)
}